import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SkAppUserVO, SkAppUserForm, SkAppUserQuery } from '@/api/app/SkAppUser/types';

/**
 * 查询app用户列表
 * @param query
 * @returns {*}
 */

export const listSkAppUser = (query?: SkAppUserQuery): AxiosPromise<SkAppUserVO[]> => {
  return request({
    url: '/app/SkAppUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询app用户详细
 * @param id
 */
export const getSkAppUser = (id: string | number): AxiosPromise<SkAppUserVO> => {
  return request({
    url: '/app/SkAppUser/' + id,
    method: 'get'
  });
};

/**
 * 新增app用户
 * @param data
 */
export const addSkAppUser = (data: SkAppUserForm) => {
  return request({
    url: '/app/SkAppUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改app用户
 * @param data
 */
export const updateSkAppUser = (data: SkAppUserForm) => {
  return request({
    url: '/app/SkAppUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除app用户
 * @param id
 */
export const delSkAppUser = (id: string | number | Array<string | number>) => {
  return request({
    url: '/app/SkAppUser/' + id,
    method: 'delete'
  });
};
/**
 * 修改app用户
 * @param data
 */
export const updateSkAppUserSetting = (data: SkAppUserForm) => {
  return request({
    url: '/app/SkAppUser/updateSkAppUserSetting',
    method: 'put',
    data: data
  });
};

export const getSum = (): AxiosPromise<SkAppUserVO> => {
  return request({
    url: '/app/SkAppUser/getSum',
    method: 'get'
  });
};

export const getSumData = (startTime: string, endTime: string) => {
  return request({
    url: '/app/SkAppUser/getSumData',
    method: 'get',
    params: {
      startTime,
      endTime
    }
  });
};
